<?php 
//include("login.php");
include("db_fns.php");
session_start();

/**
 * 这个是添加向购物车中添加商品的函数
 */
function addgoods($gid)
{
	if(isset($_SESSION["goods"]))
	{
		$_SESSION["goods"][count($_SESSION["goods"])] = $gid; 
//		$goods = $_SESSION["goods"];
//		echo "the no of goods is : ".count($goods);
	}
	else 
		$_SESSION["goods"][0] = $gid; 
}

$gid = $_SESSION["gid"];

$gids = $_SESSION["goods"];					//用来存放购物车中所有的商品ID
$goodsno = count($gids);

?>

<html>
<head> <title> Goods Cart</title></head>
<body> 
<?php 
 include("../include_htmls/header.php");   						//复用页面的头部
?>
<h2>您购物车中的商品如下所示	</h2>
<table border=1>
<tr><td>商品名称</td><td>价格</td></tr>
<?php 
/**
 * 展示购物车中的商品
 */
	$totalprice = 0;
	for($i = 0; $i < $goodsno ; $i ++)
	{
		$info = get_goodsbinfo($gids[$i]);
		
?>	
	<tr>
	<td>
	<?php 
		echo $info["gname"];
	?>
	</td>
	<td>
	<?php 
		echo $info["gprice"];
		$totalprice = $totalprice + $info["gprice"];
	?>
	</tr>
		
<?php 
	}
?>
</table>
<br/>
<p>总价：
<?php 
	echo $totalprice;
?>
</p>
<a href="order.php">进入结算中心</a>
<br/>
<br/>
<br/>
<a href="index.php">回主页</a>
</body>
</html>